namespace Plugins.Library
{
    using System;
    using System.Diagnostics.CodeAnalysis;

    public class PluginPredicateDelegateWorkItem<T> : PluginSequentialWorkItemContainer<T>
    {
        private bool _match;
        private Predicate<T> _process;

        public PluginPredicateDelegateWorkItem(T item, Predicate<T> process)
            : base(item)
        {
            this._process = process;
        }

        protected override void Process()
        {
            this._match = this._process(Item);
        }

        [SuppressMessage("Microsoft.Design", "CA1000")]
        public static void QueryAsync(Predicate<T> process, T item)
        {
            PluginSequentialWorkItemContainer<T>.QueryAsync(new PluginPredicateDelegateWorkItem<T>(item, process));
        }

        public bool Match
        {
            get
            {
                return this._match;
            }
        }
    }
}

